webpackJsonp([8],{

/***/ "/rCq":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/regenerator/index.js
var regenerator = __webpack_require__("lC5x");
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("J0Oq");
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./src/store/index.js
var store = __webpack_require__("IcnI");

// EXTERNAL MODULE: ./src/common/api/commonApi.js
var commonApi = __webpack_require__("+/+p");

// CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=script&index=0!./src/common/anjian/base/personal.vue


//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//




/* harmony default export */ var personal = ({
  name: 'personal',
  data: function data() {
    return {
      User: {},
      isShow: false,
      phoneIsShow: false,
      popupLabel: "",
      popupValue: ""
    };
  },

  methods: {
    fetchData: function fetchData() {
      var _this = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
        var user;
        return regenerator_default.a.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                user = Object(store["c" /* GetStore */])(store["f" /* Store */].user);
                _context.next = 3;
                return commonApi["a" /* commonApi */].searchById('User', user.id);

              case 3:
                _this.User = _context.sent;

                Object(store["e" /* SetStore */])(store["f" /* Store */].user, _this.User);

              case 5:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, _this);
      }))();
    },
    toModifyPwd: function toModifyPwd() {
      this.$router.$push('/base/modifyPwd');
    },
    onChange: function onChange(e) {
      var _this2 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2() {
        var files, res, user, obj;
        return regenerator_default.a.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                files = e.target.files;

                if (!(files && files.length)) {
                  _context2.next = 17;
                  break;
                }

                _context2.prev = 2;
                _context2.next = 5;
                return commonApi["a" /* commonApi */].uploadFile(files[0]);

              case 5:
                res = _context2.sent;
                user = Object(store["c" /* GetStore */])(store["f" /* Store */].user);
                obj = { id: user.id, avatar_path: res._url };
                _context2.next = 10;
                return commonApi["a" /* commonApi */].save('User', obj);

              case 10:
                _this2.fetchData();
                _this2.$Toast('上传成功!', 'success');
                _context2.next = 17;
                break;

              case 14:
                _context2.prev = 14;
                _context2.t0 = _context2['catch'](2);

                _this2.$Toast('上传失败!', 'error');

              case 17:
                e.target.value = null;

              case 18:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, _this2, [[2, 14]]);
      }))();
    },
    onChangeName: function onChangeName() {
      this.popupLabel = "新昵称";
      this.popupValue = this.User.name;
      this.isShow = true;
    },
    onChangePhoneNum: function onChangePhoneNum() {
      this.popupLabel = "手机号";
      this.popupValue = this.User.tel;
      this.phoneIsShow = true;
    },
    confirmChange: function confirmChange() {
      var _this3 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee3() {
        var obj;
        return regenerator_default.a.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                if (!_this3.popupValue) {
                  _context3.next = 8;
                  break;
                }

                obj = { id: _this3.User.id, name: _this3.popupValue };
                _context3.next = 4;
                return commonApi["a" /* commonApi */].save('User', obj);

              case 4:
                _this3.fetchData();
                _this3.isShow = false;
                _context3.next = 9;
                break;

              case 8:
                _this3.$Toast("昵称不能为空！", "error");

              case 9:
              case 'end':
                return _context3.stop();
            }
          }
        }, _callee3, _this3);
      }))();
    },
    confirmPhoneChange: function confirmPhoneChange() {
      var _this4 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee4() {
        var obj;
        return regenerator_default.a.wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                if (!_this4.popupValue) {
                  _context4.next = 8;
                  break;
                }

                obj = { id: _this4.User.id, tel: _this4.popupValue };
                _context4.next = 4;
                return commonApi["a" /* commonApi */].save('User', obj);

              case 4:
                _this4.fetchData();
                _this4.phoneIsShow = false;
                _context4.next = 9;
                break;

              case 8:
                _this4.$Toast("手机号不能为空！", "error");

              case 9:
              case 'end':
                return _context4.stop();
            }
          }
        }, _callee4, _this4);
      }))();
    }
  },
  activated: function activated() {
    this.fetchData();
  }
});
// CONCATENATED MODULE: ./node_modules/_vue-loader@13.7.3@vue-loader/lib/template-compiler?{"id":"data-v-7bcfe334","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=template&index=0!./src/common/anjian/base/personal.vue
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('yt-page',{attrs:{"title":"个人资料","type":"siample","scroll":""}},[_c('yt-split'),_vm._v(" "),_c('yt-cell',{attrs:{"label":"头像","isLink":"","border":"none"}},[_c('img',{staticClass:"avatar",attrs:{"src":_vm.User.avatar_path || __webpack_require__("Gq0m")}}),_vm._v(" "),_c('input',{ref:"input",staticClass:"upload",attrs:{"type":"file"},on:{"change":_vm.onChange}})]),_vm._v(" "),_c('yt-cell',{attrs:{"label":"昵称","isLink":"","border":"none","value":_vm.User.name},on:{"click":_vm.onChangeName}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"性别","border":"none","value":_vm.User.sex}}),_vm._v(" "),_c('yt-split'),_vm._v(" "),_c('yt-cell',{attrs:{"label":"账号","border":"none","value":_vm.User.username}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"职责","border":"none","value":_vm.User.remark || '未填写'}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"部门","border":"none","value":_vm.User.department || '未填写'}}),_vm._v(" "),_c('yt-split'),_vm._v(" "),_c('yt-cell',{attrs:{"label":"手机","isLink":"","border":"none","value":_vm.User.tel},on:{"click":_vm.onChangePhoneNum}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"邮件","border":"none","value":_vm.User.email || '未填写'}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"修改密码","isLink":"","border":"none"},on:{"click":_vm.toModifyPwd}}),_vm._v(" "),_c('yt-popup',{attrs:{"pos":"bottom","fixed":""},model:{value:(_vm.isShow),callback:function ($$v) {_vm.isShow=$$v},expression:"isShow"}},[_c('yt-cell',{attrs:{"label":_vm.popupLabel}},[_c('yt-input',{model:{value:(_vm.popupValue),callback:function ($$v) {_vm.popupValue=$$v},expression:"popupValue"}})],1),_vm._v(" "),_c('yt-btn',{attrs:{"edge":""},on:{"click":_vm.confirmChange}},[_vm._v("确定")])],1),_vm._v(" "),_c('yt-popup',{attrs:{"pos":"bottom","fixed":""},model:{value:(_vm.phoneIsShow),callback:function ($$v) {_vm.phoneIsShow=$$v},expression:"phoneIsShow"}},[_c('yt-cell',{attrs:{"label":_vm.popupLabel}},[_c('yt-input',{model:{value:(_vm.popupValue),callback:function ($$v) {_vm.popupValue=$$v},expression:"popupValue"}})],1),_vm._v(" "),_c('yt-btn',{attrs:{"edge":""},on:{"click":_vm.confirmPhoneChange}},[_vm._v("确定")])],1)],1)}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ var base_personal = (esExports);
// CONCATENATED MODULE: ./src/common/anjian/base/personal.vue
function injectStyle (ssrContext) {
  __webpack_require__("jHp+")
}
var normalizeComponent = __webpack_require__("C7Lr")
/* script */


/* template */

/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-7bcfe334"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  personal,
  base_personal,
  __vue_template_functional__,
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)

/* harmony default export */ var anjian_base_personal = __webpack_exports__["default"] = (Component.exports);


/***/ }),

/***/ "Gq0m":
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__.p + "static/img/avatar.163575a.png";

/***/ }),

/***/ "jHp+":
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ })

});